package org.cfan.seckill.service.impl;

import org.cfan.seckill.redis.RedisDao;
import org.cfan.seckill.service.FirstSecKillService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>Title: FirstSecKillServiceImpl</p>
 * <p>Date: 2017/7/10 </p>
 * <p>Description: </p>
 *
 * @author sunxinhe
 */
@Service
public class FirstSecKillServiceImpl implements FirstSecKillService {

    private static final Logger LOGGER = LoggerFactory.getLogger(FirstSecKillServiceImpl.class);

    public static final String _INVENTORY_REDIS_KEY = "inventory:01";
    public static final String _CAN_BUY_PREFIX = "canbuy:01:";

    @Autowired
    private RedisDao redisDao;

    @Override
    public String buy() {
        Integer kill = redisDao.secKill(_INVENTORY_REDIS_KEY);
        return kill.toString();
    }
}
